package homework;

/**
 * 判断玩家和电脑出拳的输赢情况
 */
public class Judge {
    private Player player = new Player();
    private Computer computer = new Computer();

    public Judge(){}
    public Judge(Player player,Computer computer){
        this.player = player;
        this.computer = computer;
    }

    public void check(){
        int num01 = player.guess();
        int num02 = computer.guess();
        if (num02 == 1){
            System.out.println("电脑出了剪刀");
        }else if (num02 == 2){
            System.out.println("电脑出了石头");
        }else{
            System.out.println("电脑出了布");
        }

        if (num02 - num01 == 1 || num02 - num01 == -2){
            System.out.println("你输了,电脑获胜");
            computer.setScore(computer.getScore() + 1);
        }else if (num02 - num01 == 0){
            System.out.println("平局");
        }else {
            System.out.println("你赢了");
            player.setScore(player.getScore() + 1);
        }
    }

    public void Fjudge(){
        if (player.getScore() > computer.getScore()){
            System.out.println(player.getName() + "，你最终分数大于电脑得分，你赢了");
        }else if (player.getScore() < computer.getScore()){
            System.out.println(player.getName() + "，电脑最终分数大于你的得分，你输了");
        }else {
            System.out.println(player.getName() + "，你和电脑的得分一样，平局");
        }
    }

}
